<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="../lib/js/juicer-min.js"></script>
    <title>Document</title>
</head>

<body>
    <h1>juicer作为前端模版渲染引擎</h1>
    <div id="tpl_test"></div>

    <script id="tpl" type="text/template">
        <ul>
            {@each list as it,index}
                <li>${it.name} (index: ${index})</li>
            {@/each}
            {@each blah as it}
                <li>
                    num: ${it.num} <br />
                    {@if it.num==3}
                        {@each it.inner as it2}
                            ${it2.time} <br />
                        {@/each}
                    {@/if}
                </li>
            {@/each}
        </ul>
    </script>

    <script>
        var data = {
            list: [
                { name: ' guokai', show: true },
                { name: ' benben', show: false },
                { name: ' dierbaby', show: true }
            ],
            blah: [
                { num: 1 },
                { num: 2 },
                {
                    num: 3, inner: [
                        { 'time': '15:00' },
                        { 'time': '16:00' },
                        { 'time': '17:00' },
                        { 'time': '18:00' }
                    ]
                },
                { num: 4 }
            ]
        };

        var tpl = document.getElementById('tpl').innerHTML;
        var html = juicer(tpl, data);

        var tpl_test = document.getElementById('tpl_test')
        tpl_test.innerHTML = html;
    </script>
</body>

</html>